<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  function fn(){
    var name = "admin";
    var age = 18;
    var sex = "男";
    function show(){
      console.log("你好，我叫" + name)
    }
    // 打包
    return {
      name: name,
      age: age,
      sex: sex,
      show: show
    };
  }

  var obj = fn();
  console.log( obj );

  console.log( obj.name );
  console.log( obj.age );
  console.log( obj.sex );
  console.log( obj.show );

  obj.show();

</script>
</html>